package main

import (
	"fmt"
	"sync"
)

var wg sync.WaitGroup

func test(num int) {
	defer wg.Done()
	for i := 0; i < 3; i++ {
		fmt.Printf("协程%v打印的第%v条数据\n", num, i)
	}

}
func main() {
	for i := 0; i < 5; i++ {
		wg.Add(1)
		go test(i)
	}
	wg.Wait() //等待所有goroutine执行完毕

}
